package com.dcdata.common;

import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

/**
 * @author: xinmi
 * @date: 2020/11/16
 * @description:
 */
public class DayTotal {

    public static void main(String argv[]){

        Calendar cal = Calendar.getInstance();
        Date now = new Date();
        cal.setTime(now);
        int month = cal.get(Calendar.MONTH) + 1;
        int year = cal.get(Calendar.YEAR);
        int day = cal.get(Calendar.DATE);
        int days0 = cal.get(Calendar.DAY_OF_YEAR);

        System.out.println("days = " + days0);

        //int year = Integer.parseInt(date.split("-")[0]);
        //int month = Integer.parseInt(date.split("-")[1]);
        //int day = Integer.parseInt(date.split("-")[2]);
        int days = (month - 1) * 30;
        switch (month) {
            case 2:
                days++;
                break;
            case 3:
                days++;
                break;
            case 4:
                days += 2;
                break;
            case 5:
                days += 2;
                break;
            case 6:
                days += 3;
                break;
            case 7:
                days += 3;
                break;
            case 8:
                days += 4;
                break;
            case 9:
                days += 5;
                break;
            case 10:
                days += 5;
                break;
            case 11:
                days += 6;
                break;
            case 12:
                days += 6;
                break;
        }
        if (month > 2) {
            if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                days--;
            } else {
                days -= 2;
            }
        }
        days += day;
        System.out.println("从" + year + "-1-1至" + year + "-" + month + "-"
                + day + "的总天dao数是:" + (days - 1));
    }
}
